<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<html>
	<head>
		<title>JSTL sql:query Tag</title>
	</head>
<body>
 
<sql:setDataSource 
	 var="snapshot" driver="com.mysql.jdbc.Driver"
     url="jdbc:mysql://127.0.0.1:3306/purejsp"
     user="root"  password="123456"/>

<sql:query dataSource="${snapshot}" var="result">
SELECT node_name from purejsp;
</sql:query>
 
<table border="1" width="100%">
	<tr>
		<th>Emp ID</th>
	</tr>
	<c:forEach var="row" items="${result.rows}">
	<tr>
		<td><c:out value="${row.node_name}"/></td>
	</tr>
	</c:forEach>
</table>

<%--事务 --%>
<sql:transaction dataSource="${snapshot}">
   <sql:update var="count">
      UPDATE purejsp SET ext_str = 'aa' WHERE Id = 1
   </sql:update>
   <sql:update var="count">
      UPDATE purejsp SET ext_str = 'bb' WHERE Id = 2
   </sql:update>
   <%-- 
   <sql:update var="count">
     INSERT INTO purejsp 
     VALUES (30,100, '2010/05/26','2010/05/26','nodeName' );
   </sql:update> --%>
</sql:transaction>

</body>
</html>